﻿#ifndef _TIME_CALC_H
#define _TIME_CALC_H

#include <stdint.h>
#include <string>
#include <QObject>

class TimeCacle:public QObject
{
    Q_OBJECT
public:
	TimeCacle();
	virtual ~TimeCacle();

    void Resum(uint32_t timeTick=0);
    void Start(uint32_t timeTick=0);
	void Stop();
    uint32_t GetTimeString(QString &tmString,QString &msecString);
    static void Format(QString &tmString,QString &msecString,const uint32_t msecTick);
    void emitTimeout();
    bool isStarted()
    {
        return m_bStart;
    }
    void reInit()
    {
        uTimeTick=0;
        m_startMs=0;
    }

public:
	static uint32_t uTimeTick;
    enum CALC_MODE
    {
        CM_ADD=0,
        CM_GET
    };

signals:
    void timeout();

private:
	bool m_bStart;
    int m_interval;
    int m_timerId;
    int m_mode;
    qint64 m_startMs;
    qint64 m_resumMs;
};

#endif
